package de.mmis.core.base.event2;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import de.mmis.core.base.ntp.NTPSync;

/**
 * Abstract event class for usage in all SmartLab related projects.
 * 
 * @author Daniel Moos
 * 
 * @param <T>
 *            the changed properties
 */
public abstract class AbstractEvent<T extends Enum<T>> implements TimedEvent,
		TypedEvent<T> {

	private long timeStamp = System.currentTimeMillis();
	private Set<T> types;

	public AbstractEvent(T... changedProperties) {
		this(new HashSet<T>(Arrays.asList(changedProperties)));
	}

	public AbstractEvent(Set<T> changedProperties) {
		timeStamp += NTPSync.getOffset();
		types = changedProperties;
	}

	@Override
	public long getTimeStamp() {
		return timeStamp;
	}

	@Override
	public Set<T> getTypes() {
		return types;
	}

}
